﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Dqs_BLL;
using Model;
using Sunny.UI;
namespace Dqs_UI
{
	public partial class frmAdmin_Class : UIForm
	{
		public frmAdmin_Class()
		{
			InitializeComponent();
		}

		Class_BLL Class_BLL = new Class_BLL();

		private void frmAdmin_Class_Load(object sender, EventArgs e)
		{
			List<ClassInfo> list = Class_BLL.GetClasses();
			dgvStudentInfo.DataSource = list;
		}

		private void btnInsertAdmin_Click(object sender, EventArgs e)
		{
			frmAddClass frmAddClass = new frmAddClass();
			frmAddClass.ShowDialog();
			frmAdmin_Class_Load(this, e);
		}

		private void btnUpdateAdmin_Click(object sender, EventArgs e)
		{
			if (dgvStudentInfo.Rows.Count == 0)
			{
				return;
			}
			int id = Convert.ToInt32(dgvStudentInfo.SelectedRows[0].Cells["Id"].Value);
			frmUpdateClass frmUpdateClass = new frmUpdateClass(id);
			frmUpdateClass.ShowDialog();
			frmAdmin_Class_Load(this, e);

		}

		private void btnDeleteAdmin_Click(object sender, EventArgs e)
		{
			if (dgvStudentInfo.Rows.Count == 0)
			{
				return;
			}
			int id = Convert.ToInt32(dgvStudentInfo.SelectedRows[0].Cells["Id"].Value);
			Class_BLL.DeleteClassInfoById(id);
			frmAdmin_Class_Load(this, e);
		}
	}
}
